﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
namespace SQT.tracnghiem.Ajax.ASP.User
{
    public partial class sign_in_user : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string name = Request.QueryString["name"];
            string username = Request.QueryString["username"];
            username = username.Trim().ToLower();
            string pass = Request.QueryString["pass"];
            string email = Request.QueryString["email"];
            string phone = Request.QueryString["phone"];
            string birthday = Request.QueryString["year"] + "-" + Request.QueryString["month"] + "-" + Request.QueryString["day"];
            string sex = Request.QueryString["sex"];
            bool bo_sex = true;
            if (sex == "0")
                bo_sex = false;

            new TblUserController().Insert("", username, pass, name, DateTime.Parse(birthday), phone, "userpic.png", email, "",null, "", bo_sex, 1, 0, true, DateTime.Now, "headerbanner.jpg", "");
            var get_last = new TblUserController().FetchAll().Last();
            Session["user"] = username;
            Session["level"] = get_last.UserLevel;
            Session["user_id"] = get_last.UserId;
            HttpCookie ck = new HttpCookie("user");
            ck.Value = get_last.UserId.ToString();
            Response.Cookies.Add(ck);
        }
    }
}